package com.lyf.language.learn.atsgg.reflect;

import org.junit.Test;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * @AUTHOR LYF
 * @DATE 2022/6/4
 * @VERSION 1.0
 * @DESC
 */
public class ClassTests {
    @Test
    public void test0(){
        try {
          Class c =   Class.forName("java.lang.String");
          String str = (String) c.newInstance();
          str+="hello";
          System.out.println(str);

          PracticeEntity practiceEntity = new PracticeEntity();

          Class pClass = practiceEntity.getClass();
          Annotation[] annotations = pClass.getDeclaredAnnotations();
          System.out.println(Arrays.toString(annotations));

          Method method = pClass.getDeclaredMethod("method1");

          System.out.println(method.getAnnotatedReturnType()+":"+method
          .getAnnotation(PersonalAnnotation.class)+":"+
                  method.getAnnotation(PersonalAnnotation.class).isPermission());


          // 三级classLoader--双亲委派
          ClassLoader classLoader=ClassLoader.getPlatformClassLoader() ;
          classLoader.loadClass("java.lang.String");




        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException e) {
            e.printStackTrace();
        }
    }




}
